package com.lizemin.inputoutput.controller;

import lombok.extern.slf4j.Slf4j;
import org.apache.catalina.filters.Constants;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * @author lzm
 * @date 2025/4/4 9:28
 * @description
 */
@Slf4j
@RestController
public class LoginController {

    @GetMapping("/login")
    public String login(HttpServletRequest request, HttpServletResponse response) {
        String token = (String) request.getAttribute(Constants.CSRF_NONCE_REQUEST_ATTR_NAME);
        log.info("csrf token为:{}", token);
        String encodeURL = response.encodeURL("http://localhost:8402/heart");
        log.info("加了csrf token的url为：{}", encodeURL);
        response.addHeader("X-Csrf-Token", token);
        return "登录成功";
    }



}
